DESCRIPTION = "hello world example"

SRC_URI  = "file://hello.c"
SRC_URI += "file://hello_client.c"
SRC_URI += "file://calculator-client.cpp"
SRC_URI += "file://calculator-server.cpp"
SRC_URI += "file://Makefile"
SRC_URI += "file://service_files/hello.service"
PV = "1.0"

LICENSE = "CLOSED"

inherit systemd
inherit obmc-phosphor-dbus-service
# inherit phosphor-dbus-yaml

SYSTEMD_SERVICE:${PN} += "hello.service"
SYSTEMD_AUTO_ENABLE:${PN} = "enable"

DEPENDS += " \
    cli11 \
    dbus \
    phosphor-dbus-interfaces \
    sdbusplus \
    systemd \
    "

do_compile() {
    ${CC} ${LDFLAGS} ../hello.c -o hello  -lsystemd
    ${CC} ${LDFLAGS} ../hello_client.c -o hello_client  -lsystemd
    ${CXX} ${LDFLAGS} -std=c++23 ../calculator-server.cpp -o calculator-server -lsystemd -lsdbusplus -lphosphor_dbus -I/home/wityuan/Desktop/openbmc/openbmc/build/evb-ast2500/tmp/sysroots-components/arm1176jzs/phosphor-dbus-interfaces/usr/include/xyz/openbmc_project/ -I/home/wityuan/Desktop/openbmc/openbmc/build/evb-ast2500/tmp/sysroots-components/arm1176jzs/sdbusplus/usr/include -I/home/wityuan/Desktop/openbmc/openbmc/build/evb-ast2500/tmp/sysroots-components/arm1176jzs/phosphor-dbus-interfaces/usr/include 
    ${CXX} ${LDFLAGS} -std=c++23 ../calculator-client.cpp -o calculator-client -lsystemd -lsdbusplus -lphosphor_dbus -I/home/wityuan/Desktop/openbmc/openbmc/build/evb-ast2500/tmp/sysroots-components/arm1176jzs/phosphor-dbus-interfaces/usr/include/xyz/openbmc_project/ -I/home/wityuan/Desktop/openbmc/openbmc/build/evb-ast2500/tmp/sysroots-components/arm1176jzs/sdbusplus/usr/include -I/home/wityuan/Desktop/openbmc/openbmc/build/evb-ast2500/tmp/sysroots-components/arm1176jzs/phosphor-dbus-interfaces/usr/include 
}

do_install () {
    install -m 0755 -d ${D}${bindir} ${D}${datadir}/hello
    install -m 0755 ${S}/hello ${D}${bindir}

    install -m 0755 ${S}/calculator-client ${D}${bindir}
    install -m 0755 ${S}/calculator-server ${D}${bindir}

    install -m 0755 -d ${D}${base_libdir}/systemd/system/ 
    install -m 0644 ${WORKDIR}/service_files/hello.service ${D}${base_libdir}/systemd/system/

    install -m 0755 ${S}/hello_client ${D}${bindir}
}

FILES:${PN} += "${bindir}/hello"
FILES:${PN} += "${bindir}/hello_client"
FILES:${PN} += "${bindir}/calculator-client"
FILES:${PN} += "${bindir}/calculator-server"
FILES:${PN} += "${base_libdir}/systemd/system/hello.service"

do_print() {
    echo "testlog: ${S}"
    echo "testlog: ${D}"
    echo "testlog: ${sysconfdir}"
    echo "testlog: ${datadir}"
    echo "testlog: ${WORKDIR}"
    echo "testlog: ${base_libdir}/systemd/system"
    echo "testlog: ${CPP}, yuan complier: ${CXX}"
    echo "testlog: cppflags: ${CPPFLAGS}"
    echo "testlog: cflags: ${CFLAGS}"
}

